
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Go 语言结构 · itcode</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="wangmaolin">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-toggle-chapters/toggle.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-advanced-emoji/emoji-website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-anchors/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="Go语言基础语法.html" />
    
    
    <link rel="prev" href="Go语言环境安装.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="http://itcode.wiki" target="_blank" class="custom-link">Home</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="./">
            
                <a href="./">
            
                    
                    Go语言学习
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="Go语言环境安装.html">
            
                <a href="Go语言环境安装.html">
            
                    
                    Go 语言环境安装
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.2.2" data-path="Go语言结构.html">
            
                <a href="Go语言结构.html">
            
                    
                    Go 语言结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="Go语言基础语法.html">
            
                <a href="Go语言基础语法.html">
            
                    
                    Go 语言基础语法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="Go语言数据类型.html">
            
                <a href="Go语言数据类型.html">
            
                    
                    Go 语言数据类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="Go语言变量&变量声明.html">
            
                <a href="Go语言变量&变量声明.html">
            
                    
                    Go 语言变量 & 变量声明
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >Go 语言结构</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="go-&#x8BED;&#x8A00;&#x7EC4;&#x6210;&#x90E8;&#x5206;"><a name="go-&#x8BED;&#x8A00;&#x7EC4;&#x6210;&#x90E8;&#x5206;" class="plugin-anchor" href="#go-&#x8BED;&#x8A00;&#x7EC4;&#x6210;&#x90E8;&#x5206;"><i class="fa fa-link" aria-hidden="true"></i></a>Go &#x8BED;&#x8A00;&#x7EC4;&#x6210;&#x90E8;&#x5206;</h1>
<p>&#x5305;&#x58F0;&#x660E;
&#x5F15;&#x5165;&#x5305;
&#x51FD;&#x6570;
&#x53D8;&#x91CF;
&#x8BED;&#x53E5; &amp; &#x8868;&#x8FBE;&#x5F0F;
&#x6CE8;&#x91CA;</p>
<h1 id="go&#x8BED;&#x8A00;&#x4EE3;&#x7801;&#x5B9E;&#x4F8B;"><a name="go&#x8BED;&#x8A00;&#x4EE3;&#x7801;&#x5B9E;&#x4F8B;" class="plugin-anchor" href="#go&#x8BED;&#x8A00;&#x4EE3;&#x7801;&#x5B9E;&#x4F8B;"><i class="fa fa-link" aria-hidden="true"></i></a>go&#x8BED;&#x8A00;&#x4EE3;&#x7801;&#x5B9E;&#x4F8B;</h1>
<pre><code>package main

import &quot;fmt&quot;

func main() {
   /* &#x8FD9;&#x662F;&#x6211;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x7B80;&#x5355;&#x7684;&#x7A0B;&#x5E8F; */
   fmt.Println(&quot;Hello, World!&quot;)
}
</code></pre><h1 id="&#x4EE5;&#x4E0A;&#x7A0B;&#x5E8F;&#x7684;&#x5404;&#x4E2A;&#x90E8;&#x5206;&#x8BF4;&#x660E;&#xFF1A;"><a name="&#x4EE5;&#x4E0A;&#x7A0B;&#x5E8F;&#x7684;&#x5404;&#x4E2A;&#x90E8;&#x5206;&#x8BF4;&#x660E;&#xFF1A;" class="plugin-anchor" href="#&#x4EE5;&#x4E0A;&#x7A0B;&#x5E8F;&#x7684;&#x5404;&#x4E2A;&#x90E8;&#x5206;&#x8BF4;&#x660E;&#xFF1A;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4EE5;&#x4E0A;&#x7A0B;&#x5E8F;&#x7684;&#x5404;&#x4E2A;&#x90E8;&#x5206;&#x8BF4;&#x660E;&#xFF1A;</h1>
<blockquote>
<p>&#x7B2C;&#x4E00;&#x884C;&#x4EE3;&#x7801; package main &#x5B9A;&#x4E49;&#x4E86;&#x5305;&#x540D;&#x3002;&#x4F60;<strong><em>&#x5FC5;&#x987B;&#x5728;&#x6E90;&#x6587;&#x4EF6;&#x4E2D;&#x975E;&#x6CE8;&#x91CA;&#x7684;&#x7B2C;&#x4E00;&#x884C;&#x6307;&#x660E;&#x8FD9;&#x4E2A;&#x6587;&#x4EF6;&#x5C5E;&#x4E8E;&#x54EA;&#x4E2A;&#x5305;</em></strong>&#xFF0C;&#x5982;&#xFF1A;package main&#x3002;package main&#x8868;&#x793A;&#x4E00;&#x4E2A;&#x53EF;&#x72EC;&#x7ACB;&#x6267;&#x884C;&#x7684;&#x7A0B;&#x5E8F;&#xFF0C;<strong><em>&#x6BCF;&#x4E2A; Go &#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x90FD;&#x5305;&#x542B;&#x4E00;&#x4E2A;&#x540D;&#x4E3A; main &#x7684;&#x5305;</em></strong>&#x3002;</p>
<p>&#x4E0B;&#x4E00;&#x884C; import &quot;fmt&quot; &#x544A;&#x8BC9; Go &#x7F16;&#x8BD1;&#x5668;&#x8FD9;&#x4E2A;&#x7A0B;&#x5E8F;&#x9700;&#x8981;&#x4F7F;&#x7528; fmt &#x5305;&#xFF08;&#x7684;&#x51FD;&#x6570;&#xFF0C;&#x6216;&#x5176;&#x4ED6;&#x5143;&#x7D20;&#xFF09;&#xFF0C;fmt &#x5305;&#x5B9E;&#x73B0;&#x4E86;&#x683C;&#x5F0F;&#x5316; IO&#xFF08;&#x8F93;&#x5165;/&#x8F93;&#x51FA;&#xFF09;&#x7684;&#x51FD;&#x6570;&#x3002;</p>
<p>&#x4E0B;&#x4E00;&#x884C; func main() &#x662F;&#x7A0B;&#x5E8F;&#x5F00;&#x59CB;&#x6267;&#x884C;&#x7684;&#x51FD;&#x6570;&#x3002;<strong><em>main &#x51FD;&#x6570;&#x662F;&#x6BCF;&#x4E00;&#x4E2A;&#x53EF;&#x6267;&#x884C;&#x7A0B;&#x5E8F;&#x6240;&#x5FC5;&#x987B;&#x5305;&#x542B;&#x7684;&#xFF0C;&#x4E00;&#x822C;&#x6765;&#x8BF4;&#x90FD;&#x662F;&#x5728;&#x542F;&#x52A8;&#x540E;&#x7B2C;&#x4E00;&#x4E2A;&#x6267;&#x884C;&#x7684;&#x51FD;&#x6570;&#xFF08;&#x5982;&#x679C;&#x6709; init() &#x51FD;&#x6570;&#x5219;&#x4F1A;&#x5148;&#x6267;&#x884C;&#x8BE5;&#x51FD;&#x6570;&#xFF09;</em></strong>&#x3002;</p>
<p>&#x4E0B;&#x4E00;&#x884C; <code>/*...*/</code>&#x662F;&#x6CE8;&#x91CA;&#xFF0C;&#x5728;&#x7A0B;&#x5E8F;&#x6267;&#x884C;&#x65F6;&#x5C06;&#x88AB;&#x5FFD;&#x7565;&#x3002;&#x5355;&#x884C;&#x6CE8;&#x91CA;&#x662F;&#x6700;&#x5E38;&#x89C1;&#x7684;&#x6CE8;&#x91CA;&#x5F62;&#x5F0F;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x5728;&#x4EFB;&#x4F55;&#x5730;&#x65B9;&#x4F7F;&#x7528;&#x4EE5; <strong><em>//</em></strong> &#x5F00;&#x5934;&#x7684;&#x5355;&#x884C;&#x6CE8;&#x91CA;&#x3002;&#x591A;&#x884C;&#x6CE8;&#x91CA;&#x4E5F;&#x53EB;&#x5757;&#x6CE8;&#x91CA;&#xFF0C;&#x5747;&#x5DF2;&#x4EE5; <code>/* &#x5F00;&#x5934;&#xFF0C;&#x5E76;&#x4EE5; */</code> &#x7ED3;&#x5C3E;&#xFF0C;&#x4E14;&#x4E0D;&#x53EF;&#x4EE5;&#x5D4C;&#x5957;&#x4F7F;&#x7528;&#xFF0C;&#x591A;&#x884C;&#x6CE8;&#x91CA;&#x4E00;&#x822C;&#x7528;&#x4E8E;&#x5305;&#x7684;&#x6587;&#x6863;&#x63CF;&#x8FF0;&#x6216;&#x6CE8;&#x91CA;&#x6210;&#x5757;&#x7684;&#x4EE3;&#x7801;&#x7247;&#x6BB5;&#x3002;</p>
<p>&#x4E0B;&#x4E00;&#x884C; fmt.Println(...) &#x53EF;&#x4EE5;&#x5C06;&#x5B57;&#x7B26;&#x4E32;&#x8F93;&#x51FA;&#x5230;&#x63A7;&#x5236;&#x53F0;&#xFF0C;&#x5E76;&#x5728;&#x6700;&#x540E;&#x81EA;&#x52A8;&#x589E;&#x52A0;&#x6362;&#x884C;&#x5B57;&#x7B26; \n&#x3002; &#x4F7F;&#x7528; fmt.Print(&quot;hello, world\n&quot;) &#x53EF;&#x4EE5;&#x5F97;&#x5230;&#x76F8;&#x540C;&#x7684;&#x7ED3;&#x679C;&#x3002; Print &#x548C; Println &#x8FD9;&#x4E24;&#x4E2A;&#x51FD;&#x6570;&#x4E5F;&#x652F;&#x6301;&#x4F7F;&#x7528;&#x53D8;&#x91CF;&#xFF0C;&#x5982;&#xFF1A;fmt.Println(arr)&#x3002;&#x5982;&#x679C;&#x6CA1;&#x6709;&#x7279;&#x522B;&#x6307;&#x5B9A;&#xFF0C;&#x5B83;&#x4EEC;&#x4F1A;&#x4EE5;&#x9ED8;&#x8BA4;&#x7684;&#x6253;&#x5370;&#x683C;&#x5F0F;&#x5C06;&#x53D8;&#x91CF; arr &#x8F93;&#x51FA;&#x5230;&#x63A7;&#x5236;&#x53F0;&#x3002;</p>
</blockquote>
<h1 id="&#x7ED3;&#x6784;&#x8BE6;&#x7EC6;&#x8BF4;&#x660E;"><a name="&#x7ED3;&#x6784;&#x8BE6;&#x7EC6;&#x8BF4;&#x660E;" class="plugin-anchor" href="#&#x7ED3;&#x6784;&#x8BE6;&#x7EC6;&#x8BF4;&#x660E;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x7ED3;&#x6784;&#x8BE6;&#x7EC6;&#x8BF4;&#x660E;</h1>
<pre><code>// &#x5F53;&#x524D;&#x7A0B;&#x5E8F;&#x7684;&#x5305;&#x540D;
package main

// &#x5BFC;&#x5165;&#x5176;&#x4ED6;&#x5305;
import &quot;fmt&quot;

// &#x5E38;&#x91CF;&#x5B9A;&#x4E49;
const PI = 3.14

// &#x5168;&#x5C40;&#x53D8;&#x91CF;&#x7684;&#x58F0;&#x660E;&#x548C;&#x8D4B;&#x503C;
var name = &quot;gopher&quot;

// &#x4E00;&#x822C;&#x7C7B;&#x578B;&#x58F0;&#x660E;
type newType int

// &#x7ED3;&#x6784;&#x7684;&#x58F0;&#x660E;
type gopher struct{}

// &#x63A5;&#x53E3;&#x7684;&#x58F0;&#x660E;
type golang interface{}

// &#x7531;main&#x51FD;&#x6570;&#x4F5C;&#x4E3A;&#x7A0B;&#x5E8F;&#x5165;&#x53E3;&#x70B9;&#x542F;&#x52A8;
func main() {
    fmt.Println(&quot;Hello World!&quot;)
}
</code></pre><h2 id="go-&#x7A0B;&#x5E8F;&#x662F;&#x901A;&#x8FC7;-package-&#x6765;&#x7EC4;&#x7EC7;&#x7684;&#x3002;"><a name="go-&#x7A0B;&#x5E8F;&#x662F;&#x901A;&#x8FC7;-package-&#x6765;&#x7EC4;&#x7EC7;&#x7684;&#x3002;" class="plugin-anchor" href="#go-&#x7A0B;&#x5E8F;&#x662F;&#x901A;&#x8FC7;-package-&#x6765;&#x7EC4;&#x7EC7;&#x7684;&#x3002;"><i class="fa fa-link" aria-hidden="true"></i></a>Go &#x7A0B;&#x5E8F;&#x662F;&#x901A;&#x8FC7; package &#x6765;&#x7EC4;&#x7EC7;&#x7684;&#x3002;</h2>
<h2 id="&#x53EA;&#x6709;-package-&#x540D;&#x79F0;&#x4E3A;-main-&#x7684;&#x5305;&#x53EF;&#x4EE5;&#x5305;&#x542B;-main-&#x51FD;&#x6570;&#x3002;"><a name="&#x53EA;&#x6709;-package-&#x540D;&#x79F0;&#x4E3A;-main-&#x7684;&#x5305;&#x53EF;&#x4EE5;&#x5305;&#x542B;-main-&#x51FD;&#x6570;&#x3002;" class="plugin-anchor" href="#&#x53EA;&#x6709;-package-&#x540D;&#x79F0;&#x4E3A;-main-&#x7684;&#x5305;&#x53EF;&#x4EE5;&#x5305;&#x542B;-main-&#x51FD;&#x6570;&#x3002;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x53EA;&#x6709; package &#x540D;&#x79F0;&#x4E3A; main &#x7684;&#x5305;&#x53EF;&#x4EE5;&#x5305;&#x542B; main &#x51FD;&#x6570;&#x3002;</h2>
<h2 id="&#x4E00;&#x4E2A;&#x53EF;&#x6267;&#x884C;&#x7A0B;&#x5E8F;&#x6709;&#x4E14;&#x4EC5;&#x6709;&#x4E00;&#x4E2A;-main-&#x5305;&#x3002;"><a name="&#x4E00;&#x4E2A;&#x53EF;&#x6267;&#x884C;&#x7A0B;&#x5E8F;&#x6709;&#x4E14;&#x4EC5;&#x6709;&#x4E00;&#x4E2A;-main-&#x5305;&#x3002;" class="plugin-anchor" href="#&#x4E00;&#x4E2A;&#x53EF;&#x6267;&#x884C;&#x7A0B;&#x5E8F;&#x6709;&#x4E14;&#x4EC5;&#x6709;&#x4E00;&#x4E2A;-main-&#x5305;&#x3002;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E00;&#x4E2A;&#x53EF;&#x6267;&#x884C;&#x7A0B;&#x5E8F;&#x6709;&#x4E14;&#x4EC5;&#x6709;&#x4E00;&#x4E2A; main &#x5305;&#x3002;</h2>
<h2 id="&#x901A;&#x8FC7;-import-&#x5173;&#x952E;&#x5B57;&#x6765;&#x5BFC;&#x5165;&#x5176;&#x4ED6;&#x975E;-main-&#x5305;&#x3002;"><a name="&#x901A;&#x8FC7;-import-&#x5173;&#x952E;&#x5B57;&#x6765;&#x5BFC;&#x5165;&#x5176;&#x4ED6;&#x975E;-main-&#x5305;&#x3002;" class="plugin-anchor" href="#&#x901A;&#x8FC7;-import-&#x5173;&#x952E;&#x5B57;&#x6765;&#x5BFC;&#x5165;&#x5176;&#x4ED6;&#x975E;-main-&#x5305;&#x3002;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x901A;&#x8FC7; import &#x5173;&#x952E;&#x5B57;&#x6765;&#x5BFC;&#x5165;&#x5176;&#x4ED6;&#x975E; main &#x5305;&#x3002;</h2>
<h2 id="&#x5305;&#x5BFC;&#x5165;&#x65B9;&#x5F0F;&#xFF1A;"><a name="&#x5305;&#x5BFC;&#x5165;&#x65B9;&#x5F0F;&#xFF1A;" class="plugin-anchor" href="#&#x5305;&#x5BFC;&#x5165;&#x65B9;&#x5F0F;&#xFF1A;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5305;&#x5BFC;&#x5165;&#x65B9;&#x5F0F;&#xFF1A;</h2>
<p>&#x901A;&#x8FC7; import &#x5173;&#x952E;&#x5B57;&#x5355;&#x4E2A;&#x5BFC;&#x5165;:</p>
<pre><code>import &quot;fmt&quot;
import &quot;io&quot;
</code></pre><p>&#x540C;&#x65F6;&#x5BFC;&#x5165;&#x591A;&#x4E2A;:</p>
<pre><code>import {
    &quot;fmt&quot;,
    &quot;io&quot;
}
</code></pre><h2 id="&#x5305;&#x8C03;&#x7528;&#x65B9;&#x5F0F;"><a name="&#x5305;&#x8C03;&#x7528;&#x65B9;&#x5F0F;" class="plugin-anchor" href="#&#x5305;&#x8C03;&#x7528;&#x65B9;&#x5F0F;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5305;&#x8C03;&#x7528;&#x65B9;&#x5F0F;</h2>
<p>&#x4F7F;&#x7528; <packagename>.<functionname> &#x8C03;&#x7528;:</functionname></packagename></p>
<pre><code>package &#x522B;&#x540D;&#xFF1A;
// &#x4E3A;fmt&#x8D77;&#x522B;&#x540D;&#x4E3A;fmt2
import fmt2 &quot;fmt&quot;
</code></pre><p>&#x7701;&#x7565;&#x8C03;&#x7528;(&#x4E0D;&#x5EFA;&#x8BAE;&#x4F7F;&#x7528;):</p>
<pre><code>// &#x8C03;&#x7528;&#x7684;&#x65F6;&#x5019;&#x53EA;&#x9700;&#x8981;Println()&#xFF0C;&#x800C;&#x4E0D;&#x9700;&#x8981;fmt.Println()
import . &quot;fmt&quot;
</code></pre><p>&#x524D;&#x9762;&#x52A0;&#x4E2A;&#x70B9;&#x8868;&#x793A;&#x7701;&#x7565;&#x8C03;&#x7528;&#xFF0C;&#x90A3;&#x4E48;&#x8C03;&#x7528;&#x8BE5;&#x6A21;&#x5757;&#x91CC;&#x9762;&#x7684;&#x51FD;&#x6570;&#xFF0C;&#x53EF;&#x4EE5;&#x4E0D;&#x7528;&#x5199;&#x6A21;&#x5757;&#x540D;&#x79F0;&#x4E86;:</p>
<pre><code>import . &quot;fmt&quot;
func main (){
    Println(&quot;hello,world&quot;)
}
</code></pre><h2 id="&#x901A;&#x8FC7;-const-&#x5173;&#x952E;&#x5B57;&#x6765;&#x8FDB;&#x884C;&#x5E38;&#x91CF;&#x7684;&#x5B9A;&#x4E49;&#x3002;"><a name="&#x901A;&#x8FC7;-const-&#x5173;&#x952E;&#x5B57;&#x6765;&#x8FDB;&#x884C;&#x5E38;&#x91CF;&#x7684;&#x5B9A;&#x4E49;&#x3002;" class="plugin-anchor" href="#&#x901A;&#x8FC7;-const-&#x5173;&#x952E;&#x5B57;&#x6765;&#x8FDB;&#x884C;&#x5E38;&#x91CF;&#x7684;&#x5B9A;&#x4E49;&#x3002;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x901A;&#x8FC7; const &#x5173;&#x952E;&#x5B57;&#x6765;&#x8FDB;&#x884C;&#x5E38;&#x91CF;&#x7684;&#x5B9A;&#x4E49;&#x3002;</h2>
<h2 id="&#x901A;&#x8FC7;&#x5728;&#x51FD;&#x6570;&#x4F53;&#x5916;&#x90E8;&#x4F7F;&#x7528;-var-&#x5173;&#x952E;&#x5B57;&#x6765;&#x8FDB;&#x884C;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x7684;&#x58F0;&#x660E;&#x548C;&#x8D4B;&#x503C;&#x3002;"><a name="&#x901A;&#x8FC7;&#x5728;&#x51FD;&#x6570;&#x4F53;&#x5916;&#x90E8;&#x4F7F;&#x7528;-var-&#x5173;&#x952E;&#x5B57;&#x6765;&#x8FDB;&#x884C;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x7684;&#x58F0;&#x660E;&#x548C;&#x8D4B;&#x503C;&#x3002;" class="plugin-anchor" href="#&#x901A;&#x8FC7;&#x5728;&#x51FD;&#x6570;&#x4F53;&#x5916;&#x90E8;&#x4F7F;&#x7528;-var-&#x5173;&#x952E;&#x5B57;&#x6765;&#x8FDB;&#x884C;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x7684;&#x58F0;&#x660E;&#x548C;&#x8D4B;&#x503C;&#x3002;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x901A;&#x8FC7;&#x5728;&#x51FD;&#x6570;&#x4F53;&#x5916;&#x90E8;&#x4F7F;&#x7528; var &#x5173;&#x952E;&#x5B57;&#x6765;&#x8FDB;&#x884C;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x7684;&#x58F0;&#x660E;&#x548C;&#x8D4B;&#x503C;&#x3002;</h2>
<h2 id="&#x901A;&#x8FC7;-type-&#x5173;&#x952E;&#x5B57;&#x6765;&#x8FDB;&#x884C;&#x7ED3;&#x6784;struct&#x548C;&#x63A5;&#x53E3;interface&#x7684;&#x58F0;&#x660E;&#x3002;"><a name="&#x901A;&#x8FC7;-type-&#x5173;&#x952E;&#x5B57;&#x6765;&#x8FDB;&#x884C;&#x7ED3;&#x6784;struct&#x548C;&#x63A5;&#x53E3;interface&#x7684;&#x58F0;&#x660E;&#x3002;" class="plugin-anchor" href="#&#x901A;&#x8FC7;-type-&#x5173;&#x952E;&#x5B57;&#x6765;&#x8FDB;&#x884C;&#x7ED3;&#x6784;struct&#x548C;&#x63A5;&#x53E3;interface&#x7684;&#x58F0;&#x660E;&#x3002;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x901A;&#x8FC7; type &#x5173;&#x952E;&#x5B57;&#x6765;&#x8FDB;&#x884C;&#x7ED3;&#x6784;(struct)&#x548C;&#x63A5;&#x53E3;(interface)&#x7684;&#x58F0;&#x660E;&#x3002;</h2>
<h2 id="&#x901A;&#x8FC7;-func-&#x5173;&#x952E;&#x5B57;&#x6765;&#x8FDB;&#x884C;&#x51FD;&#x6570;&#x7684;&#x58F0;&#x660E;&#x3002;"><a name="&#x901A;&#x8FC7;-func-&#x5173;&#x952E;&#x5B57;&#x6765;&#x8FDB;&#x884C;&#x51FD;&#x6570;&#x7684;&#x58F0;&#x660E;&#x3002;" class="plugin-anchor" href="#&#x901A;&#x8FC7;-func-&#x5173;&#x952E;&#x5B57;&#x6765;&#x8FDB;&#x884C;&#x51FD;&#x6570;&#x7684;&#x58F0;&#x660E;&#x3002;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x901A;&#x8FC7; func &#x5173;&#x952E;&#x5B57;&#x6765;&#x8FDB;&#x884C;&#x51FD;&#x6570;&#x7684;&#x58F0;&#x660E;&#x3002;</h2>
<h2 id="&#x53EF;&#x89C1;&#x6027;&#x89C4;&#x5219;"><a name="&#x53EF;&#x89C1;&#x6027;&#x89C4;&#x5219;" class="plugin-anchor" href="#&#x53EF;&#x89C1;&#x6027;&#x89C4;&#x5219;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x53EF;&#x89C1;&#x6027;&#x89C4;&#x5219;</h2>
<p>Go&#x8BED;&#x8A00;&#x4E2D;&#xFF0C;&#x4F7F;&#x7528;&#x5927;&#x5C0F;&#x5199;&#x6765;&#x51B3;&#x5B9A;&#x8BE5;&#x5E38;&#x91CF;&#x3001;&#x53D8;&#x91CF;&#x3001;&#x7C7B;&#x578B;&#x3001;&#x63A5;&#x53E3;&#x3001;&#x7ED3;&#x6784;&#x6216;&#x51FD;&#x6570;&#x662F;&#x5426;&#x53EF;&#x4EE5;&#x88AB;&#x5916;&#x90E8;&#x5305;&#x6240;&#x8C03;&#x7528;&#x3002;</p>
<p>&#x51FD;&#x6570;&#x540D;&#x9996;&#x5B57;&#x6BCD;&#x5C0F;&#x5199;&#x5373;&#x4E3A; private :</p>
<pre><code>func getId() {}
</code></pre><p>&#x51FD;&#x6570;&#x540D;&#x9996;&#x5B57;&#x6BCD;&#x5927;&#x5199;&#x5373;&#x4E3A; public :</p>
<pre><code>func Printf() {}
</code></pre><h1 id="&#x6267;&#x884C;-go-&#x7A0B;&#x5E8F;"><a name="&#x6267;&#x884C;-go-&#x7A0B;&#x5E8F;" class="plugin-anchor" href="#&#x6267;&#x884C;-go-&#x7A0B;&#x5E8F;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6267;&#x884C; Go &#x7A0B;&#x5E8F;</h1>
<blockquote>
<p>$ go run xxx.go </p>
</blockquote>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; wml 2018 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2018-07-08 14:57:28
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="Go语言环境安装.html" class="navigation navigation-prev " aria-label="Previous page: Go 语言环境安装">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="Go语言基础语法.html" class="navigation navigation-next " aria-label="Next page: Go 语言基础语法">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Go 语言结构","level":"1.2.2","depth":2,"next":{"title":"Go 语言基础语法","level":"1.2.3","depth":2,"path":"category/go/Go语言基础语法.md","ref":"category/go/Go语言基础语法.md","articles":[]},"previous":{"title":"Go 语言环境安装","level":"1.2.1","depth":2,"path":"category/go/Go语言环境安装.md","ref":"category/go/Go语言环境安装.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-lunr","-search","search-pro","toggle-chapters","splitter","donate","github","edit-link","advanced-emoji","tbfed-pagefooter","simple-page-toc","baidu","changyan","anchors","sitemap-general","livereload"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy wml 2018","modify_label":"该文件修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"github":{"url":"https://gitee.com/wmlhub/gitbook/tree/master"},"livereload":{},"simple-page-toc":{"maxDepth":3,"skipFirstH1":false},"splitter":{},"search-pro":{"cutWordLib":"nodejieba","defineWord":["gitbook-use"]},"donate":{"alipay":"","alipayText":"支付宝打赏","button":"赏","title":"","wechat":"","wechatText":"微信打赏"},"sitemap-general":{"prefix":"http://itcode.wiki"},"changyan":{"appid":"cytowLiqM","conf":"the conf in the code generate by changyan"},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"sitemap":{"hostname":"https://wmlhub.gitee.io/gitbook/"},"baidu":{"token":"084b900a1e26f6bae60e09d18e3aa455"},"advanced-emoji":{"embedEmojis":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":true,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"edit-link":{"label":"Edit This Page","base":"https://gitee.com/wmlhub/gitbook/tree/master"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchors":{},"toggle-chapters":{}},"theme":"default","author":"wangmaolin","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"itcode","language":"zh-hans","links":{"sidebar":{"Home":"http://itcode.wiki"}},"gitbook":"3.2.3","description":"记录自己日常学习总结"},"file":{"path":"category/go/Go语言结构.md","mtime":"2018-07-08T06:57:28.790Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-07-08T07:27:40.150Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-edit-link/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-baidu/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-changyan/changyan.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

